package com.song.cloud.streamRabbitmq.service.Impl;

import com.song.cloud.streamRabbitmq.service.streamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Author ZhangGuisong
 * @Date 2021/2/26-22:19
 */
@Component
@Slf4j
@EnableBinding(Source.class)
public class streamServiceImpl implements streamService {
    @Resource
    private MessageChannel messageChannel;
    @Override
    public String send() {
        String s = UUID.randomUUID().toString();
        messageChannel.send(MessageBuilder.withPayload(s).build());
        log.info("生产者在发送消息"+s);
        return null;
    }
}
